﻿using System.Collections.Generic;
using Actors;
using Common;

namespace Combat
{
    public class BattleManager : Singleton<BattleManager>
    {
        /// <summary>
        /// BattleUnit对象池，复用战斗单位对象。
        /// </summary>
        private readonly Pool<BattleUnit> m_BattleUnitPool = new Pool<BattleUnit>(() => new BattleUnit(), unit => unit.Reset());
        
        /// <summary>
        /// 敌对的战斗单位列表。
        /// </summary>
        private readonly List<BattleUnit> m_Enemies = new List<BattleUnit>();
        
        /// <summary>
        /// 友方的战斗单位列表。
        /// </summary>
        private readonly List<BattleUnit> m_Allies = new List<BattleUnit>();
        
        
        public BattleUnit CreateBattleUnit(Character character, float[] attributes)
        {
            var unit = m_BattleUnitPool.Get();
            unit.BindCharacter(character);
            unit.SetCombatAttributes(attributes);
            return unit;
        }
        
        public void ReturnBattleUnit(BattleUnit unit)
        {
            m_BattleUnitPool.Return(unit);
        }
    }
}